package client;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;

public class Client {

	public static void main(String[] args) {
		
	}
	
	private static String address = "http://localhost:9080/cnafc/service";
	
	public static Map<String,Object> connect(Map<String,Object> input){
		InputStream is = null;
		OutputStream os = null;
		try {
			URL url = new URL(address);
			HttpURLConnection connection = (HttpURLConnection) url.openConnection();
			connection.setDefaultUseCaches(false);
			connection.setUseCaches(false);
			connection.setDoInput(true);
			connection.setDoOutput(true);
			connection.setRequestMethod("POST");
			connection.setReadTimeout(10*1000);
			
			os = connection.getOutputStream();
			os.write("1111".getBytes());

			is = connection.getInputStream();
			int length = connection.getContentLength();
//			Map<String,Object> result = deserialization(is,length);
			
			connection.disconnect();
			return null;
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally{
			if(is!=null)
				try {
					is.close();
				} catch (IOException e) {}
			if(os!=null)
				try {
					os.close();
				} catch (IOException e) {}
		}
		
		
		
		
	}
}
